/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package interfaceGrafica;

import java.math.BigDecimal;
import java.util.Scanner;
import javax.swing.JOptionPane;
import Validacao.validaEntrada;

/**
 *
 * @author igor
 */
public class interfaceUsuario extends javax.swing.JFrame {

    /**
     * Creates new form interfaceUsuario
     */
    public interfaceUsuario() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDesktopPane2 = new javax.swing.JDesktopPane();
        buttonGroupSexo = new javax.swing.ButtonGroup();
        buttonGroupSexoMan = new javax.swing.ButtonGroup();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jDesktopPane3 = new javax.swing.JDesktopPane();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        nomeCad = new javax.swing.JTextField();
        cpfCad = new javax.swing.JTextField();
        salarioCad = new javax.swing.JTextField();
        masculinoCad = new javax.swing.JRadioButton();
        femininoCad = new javax.swing.JRadioButton();
        jLabel8 = new javax.swing.JLabel();
        salvarCad = new javax.swing.JButton();
        nascimentoCad = new javax.swing.JFormattedTextField();
        admissaoCad = new javax.swing.JFormattedTextField();
        jDesktopPane4 = new javax.swing.JDesktopPane();
        jLabel9 = new javax.swing.JLabel();
        cpfMan = new javax.swing.JTextField();
        nomeMan = new javax.swing.JTextField();
        buscarMan = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        salarioMan = new javax.swing.JTextField();
        salvarMan = new javax.swing.JButton();
        excluirMan = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        nascimentoMan = new javax.swing.JFormattedTextField();
        admissaoMan = new javax.swing.JFormattedTextField();
        desligamentoMan = new javax.swing.JFormattedTextField();
        sexoMan = new javax.swing.JLabel();
        jDesktopPane1 = new javax.swing.JDesktopPane();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        cpfSim = new javax.swing.JTextField();
        calcularSim = new javax.swing.JButton();
        parcelaSim = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        valorSim = new javax.swing.JTextField();
        simNome = new javax.swing.JLabel();
        simPrestacao = new javax.swing.JLabel();
        simTotal = new javax.swing.JLabel();
        simStatus = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        simNumPrestacoes = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTabbedPane2.setBackground(new java.awt.Color(204, 204, 255));

        jDesktopPane3.setBackground(new java.awt.Color(204, 204, 204));

        jLabel1.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Ficha de Cadastro");
        jLabel1.setMaximumSize(new java.awt.Dimension(218, 120));
        jLabel1.setBounds(10, 10, 620, 30);
        jDesktopPane3.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel2.setText("Nome");
        jLabel2.setBounds(20, 80, 40, 16);
        jDesktopPane3.add(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel3.setText("CPF");
        jLabel3.setBounds(400, 80, 30, 16);
        jDesktopPane3.add(jLabel3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel4.setText("Data de Nascimento");
        jLabel4.setBounds(20, 110, 130, 16);
        jDesktopPane3.add(jLabel4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel5.setText("Data de Admissão");
        jLabel5.setBounds(20, 140, 130, 16);
        jDesktopPane3.add(jLabel5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel6.setText("Salário Atual");
        jLabel6.setBounds(400, 110, 90, 16);
        jDesktopPane3.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);
        nomeCad.setBounds(70, 70, 240, 28);
        jDesktopPane3.add(nomeCad, javax.swing.JLayeredPane.DEFAULT_LAYER);
        cpfCad.setBounds(440, 70, 160, 28);
        jDesktopPane3.add(cpfCad, javax.swing.JLayeredPane.DEFAULT_LAYER);
        salarioCad.setBounds(490, 100, 110, 28);
        jDesktopPane3.add(salarioCad, javax.swing.JLayeredPane.DEFAULT_LAYER);

        masculinoCad.setBackground(new java.awt.Color(204, 204, 204));
        buttonGroupSexo.add(masculinoCad);
        masculinoCad.setText("Masculino");
        masculinoCad.setBounds(490, 140, 100, 23);
        jDesktopPane3.add(masculinoCad, javax.swing.JLayeredPane.DEFAULT_LAYER);

        femininoCad.setBackground(new java.awt.Color(204, 204, 204));
        buttonGroupSexo.add(femininoCad);
        femininoCad.setText("Feminino");
        femininoCad.setBounds(490, 170, 110, 23);
        jDesktopPane3.add(femininoCad, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel8.setText("Sexo");
        jLabel8.setBounds(390, 140, 50, 16);
        jDesktopPane3.add(jLabel8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        salvarCad.setText("Salvar Cadastro");
        salvarCad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                salvarCadActionPerformed(evt);
            }
        });
        salvarCad.setBounds(240, 210, 170, 40);
        jDesktopPane3.add(salvarCad, javax.swing.JLayeredPane.DEFAULT_LAYER);

        nascimentoCad.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter()));
        nascimentoCad.setBounds(160, 100, 150, 28);
        jDesktopPane3.add(nascimentoCad, javax.swing.JLayeredPane.DEFAULT_LAYER);

        admissaoCad.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter()));
        admissaoCad.setBounds(160, 130, 150, 28);
        jDesktopPane3.add(admissaoCad, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTabbedPane2.addTab("Cadastro", jDesktopPane3);

        jDesktopPane4.setBackground(new java.awt.Color(204, 204, 255));

        jLabel9.setText("CPF");
        jLabel9.setBounds(30, 60, 40, 16);
        jDesktopPane4.add(jLabel9, javax.swing.JLayeredPane.DEFAULT_LAYER);

        cpfMan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cpfManActionPerformed(evt);
            }
        });
        cpfMan.setBounds(80, 50, 150, 28);
        jDesktopPane4.add(cpfMan, javax.swing.JLayeredPane.DEFAULT_LAYER);
        nomeMan.setBounds(80, 90, 220, 30);
        jDesktopPane4.add(nomeMan, javax.swing.JLayeredPane.DEFAULT_LAYER);

        buscarMan.setText("Buscar");
        buscarMan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarManActionPerformed(evt);
            }
        });
        buscarMan.setBounds(230, 50, 70, 29);
        jDesktopPane4.add(buscarMan, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel10.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N
        jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel10.setText("Modificação de Cadastro");
        jLabel10.setMaximumSize(new java.awt.Dimension(186, 2230));
        jLabel10.setBounds(10, 10, 630, 20);
        jDesktopPane4.add(jLabel10, javax.swing.JLayeredPane.DEFAULT_LAYER);
        salarioMan.setBounds(500, 120, 130, 30);
        jDesktopPane4.add(salarioMan, javax.swing.JLayeredPane.DEFAULT_LAYER);

        salvarMan.setText("Salvar Cadastro");
        salvarMan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                salvarManActionPerformed(evt);
            }
        });
        salvarMan.setBounds(170, 230, 130, 40);
        jDesktopPane4.add(salvarMan, javax.swing.JLayeredPane.DEFAULT_LAYER);

        excluirMan.setText("Excluir Cadastro");
        excluirMan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                excluirManActionPerformed(evt);
            }
        });
        excluirMan.setBounds(340, 230, 130, 40);
        jDesktopPane4.add(excluirMan, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel14.setText("Nome");
        jLabel14.setBounds(30, 100, 53, 16);
        jDesktopPane4.add(jLabel14, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel15.setText("Data de Nascimento");
        jLabel15.setBounds(30, 130, 127, 16);
        jDesktopPane4.add(jLabel15, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel16.setText("Data de Admissão");
        jLabel16.setBounds(360, 70, 130, 16);
        jDesktopPane4.add(jLabel16, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel17.setText("Data de Desligamento");
        jLabel17.setBounds(360, 100, 150, 16);
        jDesktopPane4.add(jLabel17, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel18.setText("Salário Atual");
        jLabel18.setBounds(360, 130, 120, 16);
        jDesktopPane4.add(jLabel18, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel19.setText("Sexo");
        jLabel19.setBounds(360, 160, 53, 16);
        jDesktopPane4.add(jLabel19, javax.swing.JLayeredPane.DEFAULT_LAYER);

        nascimentoMan.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter()));
        nascimentoMan.setBounds(160, 120, 140, 30);
        jDesktopPane4.add(nascimentoMan, javax.swing.JLayeredPane.DEFAULT_LAYER);

        admissaoMan.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter()));
        admissaoMan.setBounds(500, 60, 130, 30);
        jDesktopPane4.add(admissaoMan, javax.swing.JLayeredPane.DEFAULT_LAYER);

        desligamentoMan.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter()));
        desligamentoMan.setBounds(500, 90, 130, 30);
        jDesktopPane4.add(desligamentoMan, javax.swing.JLayeredPane.DEFAULT_LAYER);

        sexoMan.setText("...");
        sexoMan.setBounds(500, 160, 120, 16);
        jDesktopPane4.add(sexoMan, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTabbedPane2.addTab("Manutenção do Sistema", jDesktopPane4);

        jDesktopPane1.setBackground(new java.awt.Color(255, 255, 255));

        jLabel11.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N
        jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel11.setText("Simulação de Empréstimo");
        jLabel11.setBounds(10, 10, 620, 30);
        jDesktopPane1.add(jLabel11, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel12.setText("CPF");
        jLabel12.setBounds(10, 70, 110, 16);
        jDesktopPane1.add(jLabel12, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel13.setText("Número de Parcelas (até 18x)");
        jLabel13.setBounds(10, 130, 190, 20);
        jDesktopPane1.add(jLabel13, javax.swing.JLayeredPane.DEFAULT_LAYER);

        cpfSim.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cpfSimActionPerformed(evt);
            }
        });
        cpfSim.setBounds(120, 60, 170, 28);
        jDesktopPane1.add(cpfSim, javax.swing.JLayeredPane.DEFAULT_LAYER);

        calcularSim.setText("Calcular");
        calcularSim.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                calcularSimActionPerformed(evt);
            }
        });
        calcularSim.setBounds(220, 190, 200, 40);
        jDesktopPane1.add(calcularSim, javax.swing.JLayeredPane.DEFAULT_LAYER);
        parcelaSim.setBounds(230, 120, 60, 28);
        jDesktopPane1.add(parcelaSim, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel20.setText("Valor");
        jLabel20.setBounds(10, 100, 32, 16);
        jDesktopPane1.add(jLabel20, javax.swing.JLayeredPane.DEFAULT_LAYER);
        valorSim.setBounds(130, 90, 160, 28);
        jDesktopPane1.add(valorSim, javax.swing.JLayeredPane.DEFAULT_LAYER);

        simNome.setText("...");
        simNome.setBounds(450, 80, 140, 16);
        jDesktopPane1.add(simNome, javax.swing.JLayeredPane.DEFAULT_LAYER);

        simPrestacao.setText("...");
        simPrestacao.setBounds(450, 100, 130, 16);
        jDesktopPane1.add(simPrestacao, javax.swing.JLayeredPane.DEFAULT_LAYER);

        simTotal.setText("...");
        simTotal.setToolTipText("");
        simTotal.setBounds(450, 120, 120, 16);
        jDesktopPane1.add(simTotal, javax.swing.JLayeredPane.DEFAULT_LAYER);

        simStatus.setText("...");
        simStatus.setBounds(450, 60, 160, 16);
        jDesktopPane1.add(simStatus, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel21.setText("Resultado:");
        jLabel21.setBounds(360, 60, 80, 16);
        jDesktopPane1.add(jLabel21, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel22.setText("Solicitante:");
        jLabel22.setBounds(360, 80, 80, 16);
        jDesktopPane1.add(jLabel22, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel23.setText("Prestação:");
        jLabel23.setBounds(360, 100, 64, 16);
        jDesktopPane1.add(jLabel23, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel24.setText("Número Aprovado de Prestações:");
        jLabel24.setBounds(360, 140, 220, 16);
        jDesktopPane1.add(jLabel24, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel25.setText("Valor Total:");
        jLabel25.setBounds(360, 120, 72, 16);
        jDesktopPane1.add(jLabel25, javax.swing.JLayeredPane.DEFAULT_LAYER);

        simNumPrestacoes.setText("...");
        simNumPrestacoes.setToolTipText("");
        simNumPrestacoes.setBounds(580, 140, 50, 16);
        jDesktopPane1.add(simNumPrestacoes, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTabbedPane2.addTab("Cálculo de Empréstimo", jDesktopPane1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 663, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 327, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cpfManActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cpfManActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cpfManActionPerformed

    private void cpfSimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cpfSimActionPerformed
        // TODO add your handling code here:;
    }//GEN-LAST:event_cpfSimActionPerformed

    private void calcularSimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_calcularSimActionPerformed
        Emprestimo.Emprestimo emprest = new Emprestimo.Emprestimo();

        int numPrest = 0;


        try {
            numPrest = Integer.parseInt(parcelaSim.getText());
            if (numPrest < 1) {
                numPrest = 1;
            }
            if (numPrest > 18) {
                numPrest = 18;
            }
            // Solicita o Emprestimo


            Validacao.validaEntrada.verificaNulosEmprestimo(cpfSim.getText(), valorSim.getText());
            BigDecimal valorSolicitado = BigDecimal.valueOf(Double.parseDouble(valorSim.getText()));

            emprest = Emprestimo.Emprestimo.solicitaEmp(cpfSim.getText(), valorSolicitado, numPrest);

        } catch (Exception e) {

            JOptionPane.showMessageDialog(null, e.getMessage(), "Aviso", JOptionPane.INFORMATION_MESSAGE);

        }

        // Se o empréstimo for aprovado
        if (emprest.getStatus().equalsIgnoreCase("Aprovado")) {
            simNome.setVisible(true);
            simPrestacao.setVisible(true);
            simTotal.setVisible(true);
            simStatus.setText(emprest.getStatus());
            simNome.setText(emprest.getNome());
            simPrestacao.setText(emprest.getValorPrestacao().toString());
            BigDecimal aux1 = BigDecimal.valueOf(emprest.getNumPrestacao());
            BigDecimal aux2 = emprest.getValorPrestacao().multiply(aux1);
            simTotal.setText(aux2.toString());
            simNumPrestacoes.setText(String.valueOf(numPrest));

        } else {
            simNome.setVisible(false);
            simPrestacao.setVisible(false);
            simTotal.setVisible(false);
            simStatus.setText(emprest.getStatus());
            simNome.setText(null);
            simPrestacao.setText(null);
            simTotal.setText(null);
            simNumPrestacoes.setText(null);
        }
    }//GEN-LAST:event_calcularSimActionPerformed

    // Salva um novo empregado na aba Cadastro
    private void salvarCadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarCadActionPerformed
        try {

            String cpf = cpfCad.getText();
            String nome = nomeCad.getText();
            String nasc = nascimentoCad.getText();
            String adm = admissaoCad.getText();
            String sexo = "";
            String sal = salarioCad.getText();

            if (masculinoCad.isSelected()) {
                sexo = "M";
            } else {
                sexo = "F";
            }

            validaEntrada.verificadorEntradaDados(nome, cpf, sexo, sal, nasc, adm);
            double salario = Double.valueOf(sal);
            Empregado.Empregado empr = new Empregado.Empregado(cpf, nome.toUpperCase(), sexo, nasc, adm, salario);
            Empregado.Manutencao manutencao = new Empregado.Manutencao();
            manutencao.incluirEmpregado(empr);
            JOptionPane.showMessageDialog(null, "Empregado cadastrado com sucesso!", "Aviso", JOptionPane.INFORMATION_MESSAGE);
        } catch (Empregado.Excecao ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), "Aviso", JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_salvarCadActionPerformed

    // Busca Empregado pelo CPF
    private Empregado.Empregado buscaEmpregado(String cpf) throws Empregado.Excecao {
        try {
            Empregado.Empregado empr = new Empregado.Empregado();
            Empregado.Manutencao man = new Empregado.Manutencao();
            empr = man.retornaEmpregado(cpf);
            return empr;

        } catch (Empregado.Excecao ex) {
            ex.getMessage();
            throw ex;
        }
    }

    // Preenche campos da aba Manutenção
    private void retornaCamposMan(Empregado.Empregado empr) {
        limparCamposMan();
        cpfMan.setText(empr.getCpf());
        nomeMan.setText(empr.getNome());
        salarioMan.setText(String.valueOf(empr.getSalarioAtual()));
        nascimentoMan.setText(empr.getDataNascimento().toString());
        admissaoMan.setText(empr.getDataAdmissao());


        try {
            desligamentoMan.setText(empr.getDataDesligamento());
        } catch (NullPointerException ex) {
            //JOptionPane.showMessageDialog(null, ex.getMessage(), "Aviso", JOptionPane.INFORMATION_MESSAGE);
        }



        sexoMan.setText(empr.getSexo());

        if (empr.getSexo().equalsIgnoreCase("M")) {
            sexoMan.setText("Masculino");
        } else if (empr.getSexo().equalsIgnoreCase("F")) {
            sexoMan.setText("Feminino");
        }
    }

    // Busca Empregado pelo CPF digitado na aba Manutenção
    private void buscarManActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarManActionPerformed
        try {
            retornaCamposMan(buscaEmpregado(cpfMan.getText()));
        } catch (Empregado.Excecao ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), "Aviso", JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_buscarManActionPerformed

    // Apaga campos da aba Manutenção
    private void limparCamposMan() {
        cpfMan.setText(null);
        nomeMan.setText(null);
        nascimentoMan.setText(null);
        admissaoMan.setText(null);
        salarioMan.setText(null);
        desligamentoMan.setText(null);
        sexoMan.setText("...");
    }

    // Exclui Empregado ativo na aba Manutenção
    private void excluirManActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_excluirManActionPerformed
        try {
            Empregado.Manutencao man = new Empregado.Manutencao();

            if (JOptionPane.showConfirmDialog(null, "Confirma remoção de empregado?") == 0) {
                man.excluirEmpregado(buscaEmpregado(cpfMan.getText()));
                JOptionPane.showMessageDialog(null, "Empregado removido com sucesso!", "Aviso", JOptionPane.INFORMATION_MESSAGE);

            } else {
                JOptionPane.showMessageDialog(null, "Empregado não foi removido!", "Aviso", JOptionPane.INFORMATION_MESSAGE);
            }

            limparCamposMan();

        } catch (Empregado.Excecao ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), "Aviso", JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_excluirManActionPerformed

    // Salva modificações feitas em um empregado na aba Manutenção
    private void salvarManActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarManActionPerformed
        try {
            String cpf = cpfMan.getText();
            String nome = nomeMan.getText();
            String nasc = nascimentoMan.getText();
            String adm = admissaoMan.getText();
            String sal = salarioMan.getText();
            String desl = desligamentoMan.getText();
            String sexo = null;
            if ("Masculino".equals(sexoMan.getText())) {
                sexo = "M";
            } else {
                sexo = "F";
            }

            if (desl.equalsIgnoreCase(null) || desl.equalsIgnoreCase("")) {
                validaEntrada.verificadorEntradaDados(nome, cpf, sexo, sal, nasc, adm);
            } else {
                validaEntrada.verificadorEntradaDados(nome, cpf, sexo, sal, nasc, adm, desl);
            }

            double salario = Double.valueOf(sal);

            Empregado.Empregado emp;

            if (desl == (null) || desl == ("")) {
                emp = new Empregado.Empregado(cpf, nome.toUpperCase(), sexo, nasc, adm, salario);
            } else {
                emp = new Empregado.Empregado(cpf, nome.toUpperCase(), sexo, nasc, adm, salario, desl);
            }

            Empregado.Manutencao man = new Empregado.Manutencao();

            man.alterarEmpregado(emp);

            JOptionPane.showMessageDialog(null, "Dados alterados com sucesso!", "Aviso", JOptionPane.INFORMATION_MESSAGE);

            limparCamposMan();

        } catch (Empregado.Excecao ex) {

            JOptionPane.showMessageDialog(null, ex.getMessage(), "Aviso", JOptionPane.INFORMATION_MESSAGE);

        }
    }//GEN-LAST:event_salvarManActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(interfaceUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(interfaceUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(interfaceUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(interfaceUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new interfaceUsuario().setVisible(true);

                Scanner leituraEmprestimo = new Scanner(System.in);

            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JFormattedTextField admissaoCad;
    private javax.swing.JFormattedTextField admissaoMan;
    private javax.swing.JButton buscarMan;
    private javax.swing.ButtonGroup buttonGroupSexo;
    private javax.swing.ButtonGroup buttonGroupSexoMan;
    private javax.swing.JButton calcularSim;
    private javax.swing.JTextField cpfCad;
    private javax.swing.JTextField cpfMan;
    private javax.swing.JTextField cpfSim;
    private javax.swing.JFormattedTextField desligamentoMan;
    private javax.swing.JButton excluirMan;
    private javax.swing.JRadioButton femininoCad;
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JDesktopPane jDesktopPane2;
    private javax.swing.JDesktopPane jDesktopPane3;
    private javax.swing.JDesktopPane jDesktopPane4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JRadioButton masculinoCad;
    private javax.swing.JFormattedTextField nascimentoCad;
    private javax.swing.JFormattedTextField nascimentoMan;
    private javax.swing.JTextField nomeCad;
    private javax.swing.JTextField nomeMan;
    private javax.swing.JTextField parcelaSim;
    private javax.swing.JTextField salarioCad;
    private javax.swing.JTextField salarioMan;
    private javax.swing.JButton salvarCad;
    private javax.swing.JButton salvarMan;
    private javax.swing.JLabel sexoMan;
    private javax.swing.JLabel simNome;
    private javax.swing.JLabel simNumPrestacoes;
    private javax.swing.JLabel simPrestacao;
    private javax.swing.JLabel simStatus;
    private javax.swing.JLabel simTotal;
    private javax.swing.JTextField valorSim;
    // End of variables declaration//GEN-END:variables
}
